<template>
	<!-- <view class="diy-banner-box mb20 pr" :class="itemData.style.imgShape"
		:style="'background-color:'+itemData.style.background+';'"> -->
	<view class="diy-banner-box mb20 pr" :class="itemData.style.imgShape" :style="'margin-top:'+itemData.style.paddingTop+'px;'">
		<swiper :indicator-dots="indicatorDots" class="swiper" :indicator-active-color="indicatorActiveColor" :autoplay="autoplay" :interval="interval" :duration="duration" @change="changeSwiper"  :style="itemData.style.imgShape=='square'?'height:'+itemData.style.height+'rpx;':'height:'+(itemData.style.height*0.92)+'rpx;'" :circular="true">
			<swiper-item v-for="(item,index) in itemData.data" :key="index" @click="gotoPages(item)">
				<image class="imgStyleBannerSwiper" :style="itemData.style.imgShape=='square'?'height:'+itemData.style.height+'rpx;':'height:'+(itemData.style.height*0.92)+'rpx;'" :src="item.imgUrl"></image>
			</swiper-item>
		</swiper>
		<view class="swiper-dots ww100 d-c-c" :class="itemData.style.btnShape">
			<view :class="current==index?'swiper-dot active':'swiper-dot'" v-for="(item,index) in itemData.data"
				:style="current==index?'background-color:'+indicatorActiveColor+';':''" :key="index">
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				indicatorDots: false,
				autoplay: true,
				interval: 2000,
				duration: 500,
				indicatorActiveColor: '#ffffff',
				current: 0
			}
		},
		props: ['itemData'],
		created() {
			this.interval = this.itemData.params.interval;
			this.indicatorActiveColor = this.itemData.style.btnColor;
		},
		methods: {
			changeSwiper(e) {
				this.current = e.detail.current;
			},
			/*跳转页面*/
			gotoPages(e) {
				let dog = e.linkUrl?e.linkUrl:e.name
				// dog = dog + ""
				console.log(dog)
				// uni.navigateTo({
				// 	url: dog
				// })
				uni.navigateTo({
					url: dog
				})
				// uni.navigateTo({
				// 	url: JSON.stringify(e.linkUrl?e.linkUrl:e.name)
				// })
				// uni.navigateTo({
				// 	url: e.linkUrl?e.linkUrl:e.name
				// })
				// console.log(e.linkUrl,'outside')
				// this.$store.dispatch('goToPage',e.linkUrl)
				// gotopage(e.linkUrl);
			}
		}
	}
</script>

<style>
	.swiper{
		border-radius: 12px;
	}
	.imgStyleBannerSwiper{
		border-radius: 12px;
	}
	.diy-banner-box{
		overflow: hidden;
		border-radius: 12px;
		position: relative;
	}
	.diy-banner-box,
	.diy-banner-box .swiper {
		/* width: 750rpx; */
		
		/* background-color: #FFFFFF; */
	}

	.diy-banner-box.round,
	.diy-banner-box.round .swiper {
		/* width: 750rpx; */
		/* background-color: #FFFFFF; */
	}

	.diy-banner-box image {
		width: 750rpx;
	}
	.diy-banner-box.round{
		/* padding: 30rpx; */
		box-sizing: border-box;
	}
	.diy-banner-box.round image {
		width: 690rpx;
		/* border-radius: 12rpx; */
	}

	.diy-banner-box .swiper-dots {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}
	.diy-banner-box.round .swiper-dots {
		position: absolute;
		bottom: 20rpx;
		left: 0;
		right: 0;
		margin: auto;
	}

	.diy-banner-box.square .swiper-dots {
		position: absolute;
		bottom: 20rpx;
		left: 0;
		right: 0;
		margin: auto;
	}

	.swiper-dots.square .swiper-dot {
		width: 14rpx;
		height: 14rpx;
		margin: 0 4rpx;
		background: #ebedf0;
		opacity: 0.3;
	}

	.swiper-dots.round .swiper-dot {
		width: 22rpx;
		height: 22rpx;
		margin: 0 4rpx;
		background: #ebedf0;
		opacity: 0.3;
		border-radius: 50%;
	}

	.swiper-dots.rectangle .swiper-dot {
		width: 15rpx;
		height: 8rpx;
		margin: 0 4rpx;
		background: #ebedf0;
		opacity: 0.3;
		border-radius: 4rpx;
	}

	.swiper-dots.round .swiper-dot.active,
	.swiper-dots.square .swiper-dot.active,
	.swiper-dots.rectangle .swiper-dot.active {
		opacity: 1;
	}
	
	.swiper-dots.rectangle .swiper-dot.active {
		width: 40rpx;
	}
</style>
